package com.myk.game.gobangchess.signs;

import com.myk.game.gobangchess.Sign;
import com.myk.game.gobangchess.utils.Pair;

import java.util.List;

/**
 * 路径标记，可一定程度上自由随意的在棋盘上绘制图形
 */
public class PathSign extends Sign {

    private final List<Pair<Integer, Integer>> nodes; //点集，每个point由“index"+ "w" +"pos”组成， 例如"13w1"，index同其它标记，pos为以这个格子为锚点自身的9个位置,0-8,从左到右从上到下数，点之间用“a”拼接
    private final String liColor; //线颜色
    private final String grColor; //封闭图形颜色
    private final float size; //线的宽度比例
    private final int style; //线条样式 0:实线， 1:虚线

    public PathSign(List<Pair<Integer, Integer>> nodes, String liColor, String grColor, float size, int style) {
        this.nodes = nodes;
        this.liColor = liColor;
        this.grColor = grColor;
        this.size = size;
        this.style = style;
    }

    @Override
    public String getSignInfo() {
        return type + "," + getNodesStr() + "," + liColor + "," + grColor + "," + size + "," + style;
    }

    private String getNodesStr() {
        StringBuilder sb = new StringBuilder();
        for (Pair<Integer, Integer> tile : nodes) {
            sb.append(tile.first).append("w").append(tile.second).append("a");
        }
        sb.deleteCharAt(sb.length() - 1);
        return sb.toString();
    }

}
